package dbcp.shia.service.impl;

import dbcp.shia.dao.PexProgramDao;
import dbcp.shia.entity.PexProgram;
import dbcp.shia.service.PexProgramService;

import java.util.List;

public class PexProgramServiceImpl implements PexProgramService {

    private static PexProgramDao pexProgramDao;

    static {
        pexProgramDao = new PexProgramDao();
    }

    public PexProgram getPexProgram(String programCode) {
        List<PexProgram> pexProgramList = pexProgramDao.findPexProgram(programCode);

        PexProgram pexProgram = null;
        if (pexProgramList.size() > 0) {
            pexProgram = pexProgramList.get(0);
        }

        return pexProgram;
    }

    public List<PexProgram> getPexPrograms() {
        return pexProgramDao.findPexProgram(null);
    }

    public void savePexProgram(PexProgram pexProgram) {
        pexProgramDao.savePexProgram(pexProgram);
    }

    public void savePexProgramList(List<PexProgram> pexProgramList) {
        pexProgramDao.savePexProgramList(pexProgramList);
    }
}
